import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Progress extends CustomPainter {
  final String color;
  final Offset p1;
  final Offset p2;
  Progress(
      {this.color = '0xffe2e2e2',
      this.p1 = const Offset(0, 40),
      this.p2 = const Offset(0, 20)});

  @override
  void paint(Canvas canvas, Size size) {
    // 画背景
    var paint = Paint()
      ..isAntiAlias = false
      ..strokeWidth = 5
      ..color = Color(int.parse(color));
    canvas.drawLine(p1, p2, paint..strokeCap);
  }

  //在实际场景中正确利用此回调可以避免重绘开销，本示例我们简单的返回true
  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true;
}
